package com.fyp.jdbc;

/**    
* JDBCTest.java  
* Version 1.0  
* Get connection with MySQL 
*/  

import java.sql.Connection;   
import java.sql.DriverManager;     
import java.sql.SQLException;  

public class JDBCTest {   
	private static Connection conn = null;   
	private static final String URL = "jdbc:mysql://127.0.0.1:3306/fyp";
	private static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";   
	private static final String USER_NAME = "root";   
	private static final String PASSWORD = "";
	
	public static Connection getConnection() {   
		try {   
			Class.forName(JDBC_DRIVER);   
			conn = DriverManager.getConnection(URL, USER_NAME, PASSWORD);
			//System.out.println("Success");
		} catch (ClassNotFoundException e) {
			//System.out.println("Error");
			e.printStackTrace();   
		} catch (SQLException e) {  
			//System.out.println("Error");
			e.printStackTrace();   
		}
		if(conn == null){
			System.out.println("Connection Fail");
		}else{
			System.out.println("Success!");
		}
		return conn;   
	}
	public static void main(String[] args) {
		getConnection();
	}
}